<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap</title>
    <link rel="stylesheet" href="${ctx}/bootstrap/bootstrap.css">

</head>
<body>
<div class="container" style="margin-top: 30px">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="form-inline">
                <form>
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>
                           姓名 <input type="text" name="name">
                        </th>
                        <th>
                            手机<input type="text" name="phone">
                        </th>
                        <th>
                           密码 <input type="text" name="password">
                        </th>
                        <th>
                          密码  <input type="text" name="password2">
                        </th>
                    </tr>
                    </thead>
                </table>
                <input type="button" onclick="zc()"value="注册">
                </form>
            </div>
        </div>
    </div>
</div>
<script src="${ctx}/bootstrap/jquery-1.9.1.min.js"></script>
<script src="${ctx}/bootstrap/jquery.validate.min.js"></script>
<script src="${ctx}/bootstrap/messages_zh.js"></script>
<script src="${ctx}/bootstrap/bootstrap.js"></script>
<script>
    function zc() {
        var v = $("form").valid();
        if(v){
            var password = $('[name="password"]').val();
            var password2 = $('[name="password2"]').val();
            if(password != password2){
                alert("二次密码不一样")
                return;
            }
            $.post("${ctx}/save.do",$('form').serialize(),function (res) {
                if(res){
                    alert("注册成功")
                    location.href="${ctx}/loginlist.do"
                }else {
                    alert("注册失败")
                }
            })
        }
    }
</script>
</body>
</html>